<!--
 * @Descripttion: 
 * @version: 
 * @Author: lyw
 * @Date: 2022-03-05 21:26:49
 * @LastEditors: lyw
 * @LastEditTime: 2022-03-06 20:53:02
-->
<template>
  <div id="uesrtext">
    <textarea
      placeholder="按 Enter 发送"
      v-model="content"
      @keyup.enter="addMessage"
    ></textarea>
    <el-button type="primary" class="button" @click="addMessage">发送</el-button>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "uesrtext",
  data() {
    return {
      content: "",
    };
  },
  methods: {
    addMessage(e) {
      if (this.content.length) {
        this.$store.commit("addMessage", this.content);
        this.content = "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
#uesrtext {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 130px;
  border-top: solid 1px #ddd;
  > textarea {
    padding: 10px;
    width: 449px;
    height: 83%;
    border: none;
    outline: none;
    float: left;
  }
}
.button {
  float: left;
  height: 129px;
  border-radius: 10px;
}
</style>
